package com.siao.example.libaray.component.view
{
	import com.siao.component.Orientation;
	import com.siao.component.Stack;
	import com.siao.display.Align;
	import com.siao.display.LayoutElement;
	import com.siao.example.common.ui.Layer;
	import com.siao.mvc.View;
	
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	/**
	 * 堆栈视图
	 * @author SiaoLeon
	 */
	public class ComponentStackView extends View
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		private var stack:Stack;
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 */
		public function ComponentStackView()
		{
			super();
			
			this.stack = new Stack(Orientation.LEFT_RIGHT);
			this.stack.draw(0X000000, 0.2);
			this.stack.margin = 10;
			this.stack.marginTop = 80;
			this.stack.spacing = 1;
			
			this.stack.contentAlignH = Align.CENTER;
			this.stack.contentAlignV = Align.CENTER;
			
			for (var i:int = 0; i < 5; i++)
			{
				var sprite:LayoutElement = new LayoutElement();
				sprite.draw(0XFF0000, 0.8);
				sprite.width = 40 + i * 2;
				sprite.height = 40 + i * 2;
				sprite.margin = 1;
				
				if (i == 3)
				{
					sprite.alignV = Align.TOP;
				}
				
				var text:TextField = new TextField();
				text.autoSize = TextFieldAutoSize.LEFT;
				text.border = true;
				text.text = i.toString();
				sprite.addChild(text);
				
				this.stack.addChild(sprite);
			}
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		override public function onAdd():void
		{
			Layer.instance.content.addChild(this.stack);
		}
		
		override public function onRemove():void
		{
			Layer.instance.content.removeChild(this.stack);
		}
	
		// -------------------------------------------------------------------------------------------------------- 函数
	
	}
}
